package cn.sw.cloudmybatisplus.common.controller;

// BaseController 封装公共请求

import cn.sw.cloudmybatisplus.common.http.HttpResponse;
import cn.sw.cloudmybatisplus.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

public class BaseController<T, F, Q> {
//    采用了spring扩展，自动注入，不用这个注入 忽略该警告
    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    protected BaseService<T, F, Q> baseService;

    @GetMapping("/RById/{id}")
    public HttpResponse<?> RById(@PathVariable("id") String id) {
        return baseService.RById(id);
    }

    @PostMapping("/RByIds")
    public HttpResponse<?> RByIds(@RequestBody List<String> idList) {
        return baseService.RByIds(idList);
    }

    @PostMapping("/R")
    public HttpResponse<?> R(@RequestBody Q query) {
        return baseService.R(query);
    }

    @PostMapping("/C")
    public HttpResponse<?> C(@RequestBody F form) {
        return baseService.C(form);
    }

    @PostMapping("/CBatch")
    HttpResponse<?> CBatch(@RequestBody List<F> formList) {
        return baseService.CBatch(formList);
    }

    @PostMapping("/UById")
    HttpResponse<?> UById(@RequestBody F form) {
        return baseService.UById(form);
    }

    @PostMapping("/UBatchById")
    HttpResponse<?> UBatchById(@RequestBody List<F> formList) {
        return baseService.UBatchById(formList);
    }

    @PostMapping("/COrU")
    HttpResponse<?> COrU(F form) {
        return baseService.COrU(form);
    }

    @PostMapping("/COrUBatch")
    HttpResponse<?> COrUBatch(@RequestBody List<F> formList) {
        return baseService.COrUBatch(formList);
    }

    @GetMapping("/DById/{id}")
    HttpResponse<?> DById(@PathVariable("id") String id) {
        return baseService.DById(id);
    }

    @PostMapping("/DByIds")
    HttpResponse<?> DByIds(@RequestBody List<String> idList) {
        return baseService.DByIds(idList);
    }
}